<template>
  <el-row :gutter="40" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="card-panel" @click="getData()" style="background:#6AC6FF">
        <div class="card-panel-description">
          <div class="img"><img src="../../../../src/assets/img/p1.png"></div>
          <div class="content">
            <count-to :start-val="0" :end-val="newVipCardNum" :duration="duration" class="card-panel-num" />
            <div class="card-panel-text">新增会员数量</div>
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="card-panel" @click="getData()" style="background:#FCAD7E">
        <div class="card-panel-description">
          <div class="img"><img src="../../../../src/assets/img/p2.png"></div>
          <div class="content">
            <count-to :start-val="0" :end-val="sankeAmount" :duration="duration" class="card-panel-num" />
            <div class="card-panel-text">散客消费金额</div>
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="card-panel" @click="getData()" style="background:#4ECACA">
        <div class="card-panel-description">
          <div class="img"><img src="../../../../src/assets/img/p3.png"></div>
          <div class="content">
            <count-to :start-val="0" :end-val="vipAmount" :duration="duration" class="card-panel-num" />
            <div class="card-panel-text">会员消费金额</div>
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="card-panel" @click="getData()" style="background:#FF8C7F">
        <div class="card-panel-description">
          <div class="img"><img src="../../../../src/assets/img/p4.png"></div>
          <div class="content">
            <count-to :start-val="0" :end-val="vipChargeAmount" :duration="duration" class="card-panel-num" />
            <div class="card-panel-text">新开卡及续卡</div>
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="5" class="card-panel-col">
      <div class="card-panel" @click="getData()" style="background:#53C9B1">
        <div class="card-panel-description">
          <div class="img"><img src="../../../../src/assets/img/p5.png"></div>
          <div class="content">
            <count-to :start-val="0" :end-val="allAmount" :duration="duration" class="card-panel-num" />
            <div class="card-panel-text">综合收入</div>
           </div>       
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from "vue-count-to";

export default {
  components: {
    CountTo
  },
  data() {
    return {
      duration: 1500,
      newVipCardNum: 0,
      sankeAmount: 0,
      vipAmount: 0,
      vipChargeAmount: 0,
      allAmount: 0
    };
  },
  activated() {
    this.getData()
  },
  methods: {
    // 获取展示的数据
    getData() {
      this.newVipCardNum = 0
      this.$http({
        url: this.$http.adornUrl("/index/data"),
        method: "get",
        params: this.$http.adornParams({})
      }).then(({ data }) => {
        if (data && data.code == 0) {
          this.newVipCardNum = data.data.newVipCardNum
          this.sankeAmount = data.data.sankeAmount
          this.vipAmount = data.data.vipAmount
          this.vipChargeAmount = data.data.vipChargeAmount
          this.allAmount = data.data.allAmount
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    border-radius: 10px;

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3;
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3;
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      // float: right;
      font-weight: bold;
      margin: 26px;
      display: flex;

      .img{
        width:40px;
        height:40px;
        background:rgba(0,0,0,.4);
        border-radius:50%;
        text-align:center;
        line-height:40px;
        margin:10px 10px 0 0;

        img{
          width:20px;
          height:20px;

        }
      }
      
      .content{
        color: #fff;

        .card-panel-text {
          line-height: 18px;
          font-size: 14px;
          margin-bottom: 12px;
        }

        .card-panel-num {
          font-size: 20px;
          display:inline-block;
          margin-bottom:15px;
        }
      }
    }
  }
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
@media (min-width: 1200px) {
  .el-col-lg-5 {
    width:20%;
  }
}
</style>
